﻿using System;
using SizeboxUI;
using UnityEngine;

// Token: 0x020003A2 RID: 930
public class MainInput : MonoBehaviour
{
	// Token: 0x06001863 RID: 6243 RVA: 0x0009A442 File Offset: 0x00098642
	private void Start()
	{
		this.controller = base.GetComponent<GameController>();
		this.view = this.controller.view;
		this.cameraEffects = base.GetComponent<CameraEffectsSettings>();
	}

	// Token: 0x06001864 RID: 6244 RVA: 0x0009A470 File Offset: 0x00098670
	private void Update()
	{
		if (GameController.Instance.paused || GameController.Instance.userIsTyping)
		{
			return;
		}
		if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(ButtonInput.EscapeAlt))
		{
			this.view.OpenPauseMenu();
		}
		if (Input.GetButtonDown(ButtonInput.IncreaseGtsAnimSpeed))
		{
			GameController.IncreaseSpeed();
		}
		if (Input.GetButtonDown(ButtonInput.DecreaseGtsAnimSpeed))
		{
			GameController.DecreaseSpeed();
		}
		if (Input.GetButtonDown(ButtonInput.PauseGiantess))
		{
			if (!this.gtsIsPaused)
			{
				if (this.slowmoActive)
				{
					this.SlowmoOff();
				}
				if (GameController.globalSpeed != 0f)
				{
					this.gtsPausedSpeed = GameController.globalSpeed;
				}
				else
				{
					this.gtsPausedSpeed = 1f;
				}
				GameController.globalSpeed = 0f;
				this.gtsIsPaused = true;
				ObjectManager.Instance.UpdateAllSpeeds();
			}
			else
			{
				if (this.slowmoActive)
				{
					Debug.Log("SLOWMO SHOULD NOT BE ON");
					this.SlowmoOff();
				}
				if (this.gtsPausedSpeed > 0f)
				{
					GameController.globalSpeed = this.gtsPausedSpeed;
				}
				else
				{
					GameController.globalSpeed = 1f;
				}
				this.gtsIsPaused = false;
				ObjectManager.Instance.UpdateAllSpeeds();
			}
		}
		if (Input.GetButton(ButtonInput.SlowMotion))
		{
			if (!this.gtsIsPaused && !this.slowmoActive)
			{
				this.SlowmoOn();
			}
		}
		else if (!this.gtsIsPaused && this.slowmoActive)
		{
			this.SlowmoOff();
		}
		if (Input.GetButtonDown(ButtonInput.EditMode))
		{
			this.view.ChangeMode();
		}
		if (Input.GetButtonDown(ButtonInput.ToggleLookAtPlayer))
		{
			this.ToggleLookAtPlayer();
		}
		if (Input.GetKeyDown(KeyCode.F10))
		{
			this.view.Take360Screenshot();
		}
		if (Input.GetButtonDown(ButtonInput.TakeScreenshot))
		{
			this.view.TakeScreenshot();
		}
		if (this.view.mode == MainView.Mode.Edit)
		{
			if (Input.GetKeyDown(KeyCode.O))
			{
				this.view.editMode.OnCatalogClick(0);
			}
			if (Input.GetKeyDown(KeyCode.G))
			{
				this.view.editMode.OnCatalogClick(1);
			}
			if (Input.GetKeyDown(KeyCode.P))
			{
				this.view.editMode.OnCatalogClick(2);
			}
			if (Input.GetKeyDown(KeyCode.M))
			{
				this.view.editMode.placement.MoveCurrentGO();
			}
			if (Input.GetKeyDown(KeyCode.Delete))
			{
				this.view.editMode.OnDeleteClick();
			}
		}
	}

	// Token: 0x06001865 RID: 6245 RVA: 0x0009A709 File Offset: 0x00098909
	private void ToggleLookAtPlayer()
	{
		GlobalPreferences.LookAtPlayer.value = !GlobalPreferences.LookAtPlayer.value;
	}

	// Token: 0x06001866 RID: 6246 RVA: 0x0009A722 File Offset: 0x00098922
	private void SlowmoOn()
	{
		this.speedBeforeSlow = GameController.globalSpeed;
		GameController.globalSpeed /= (float)this.slowmoFactor;
		ObjectManager.Instance.UpdateAllSpeeds();
		this.slowmoActive = true;
	}

	// Token: 0x06001867 RID: 6247 RVA: 0x0009A752 File Offset: 0x00098952
	private void SlowmoOff()
	{
		GameController.globalSpeed = this.speedBeforeSlow;
		ObjectManager.Instance.UpdateAllSpeeds();
		this.slowmoActive = false;
	}

	// Token: 0x06001868 RID: 6248 RVA: 0x0009A770 File Offset: 0x00098970
	private void OnDestroy()
	{
		if (this.gtsIsPaused)
		{
			if (this.gtsPausedSpeed > 0f)
			{
				GameController.globalSpeed = this.gtsPausedSpeed;
			}
			else
			{
				GameController.globalSpeed = 0.1f;
			}
			if (Input.GetButton(ButtonInput.SlowMotion))
			{
				GameController.globalSpeed /= (float)this.slowmoFactor;
			}
			this.gtsIsPaused = false;
			ObjectManager.Instance.UpdateAllSpeeds();
		}
		if (this.slowmoActive)
		{
			GameController.globalSpeed = this.speedBeforeSlow;
			ObjectManager.Instance.UpdateAllSpeeds();
			this.slowmoActive = false;
		}
	}

	// Token: 0x04001A87 RID: 6791
	private GameController controller;

	// Token: 0x04001A88 RID: 6792
	private CameraEffectsSettings cameraEffects;

	// Token: 0x04001A89 RID: 6793
	private MainView view;

	// Token: 0x04001A8A RID: 6794
	private float startPushMale;

	// Token: 0x04001A8B RID: 6795
	private float startPushFemale;

	// Token: 0x04001A8C RID: 6796
	private bool gtsIsPaused;

	// Token: 0x04001A8D RID: 6797
	private float gtsPausedSpeed;

	// Token: 0x04001A8E RID: 6798
	private int slowmoFactor = 8;

	// Token: 0x04001A8F RID: 6799
	private bool slowmoActive;

	// Token: 0x04001A90 RID: 6800
	private float speedBeforeSlow;
}
